﻿using Ebusiness_Application_Contracts.Iservice;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
using Volo.Abp.SettingManagement;
using Volo.Abp.Settings;

namespace Ebusiness_Application.Service
{
    [Dependency(ServiceLifetime.Transient)]
    public class SettingService : ApplicationService, ISettingService, IRemoteService
    {
        public ISettingManager settingManager { get; set; }

        public ISettingProvider settingProvider { get; set; }

        /// <summary>
        /// 全局设置
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public async Task<string> Set(string name, string value)
        {
            //获取定义配置
            string? seeting = await settingProvider.GetOrNullAsync("ProductTest");
            //存储配置
            //await settingManager.SetGlobalAsync(name, value);
            return "结果测试";
        }

        /// <summary>
        /// 设置用户配置值
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public async Task<string> SetUser(Guid guid, string name, string value)
        {
            //存储配置
            await settingManager.SetForUserAsync(guid, name, value);
            return "结果测试";
        }
    }
}
